| @@ -1,17 +1,18 @@ | ||
| 1 | 1 | module Agents | 
| 2 | - class QpxAgent < Agent | |
| 2 | + class GoogleFlightsAgent < Agent | |
| 3 | + include FormConfigurable | |
| 3 | 4 |  | 
| 4 | 5 | cannot_receive_events! | 
| 5 | 6 | default_schedule "every_12h" | 
| 6 | 7 |  | 
| 7 | 8 |  | 
| 8 | 9 | description <<-MD | 
| 9 | - The QpxExpressAgent will tell you the minimum airline prices between a pair of cities. The api limit is 50 requests/day. | |
| 10 | + The GoogleFlightsAgent will tell you the minimum airline prices between a pair of cities. The api limit is 50 requests/day. | |
| 10 | 11 |  | 
| 11 | 12 | Follow their documentation here (https://developers.google.com/qpx-express/v1/prereqs#get-a-google-account) to retrieve an api key. | 
| 12 | 13 | After you get to the google developer console, created a project, enabled qpx express api then you can choose `api key` credential to be created. | 
| 13 | 14 |  | 
| 14 | - `Origin` and `Destination` requires `airport code`. | |
| 15 | + The `origin` and `destination` options require an [airport code](http://www.expedia.com/daily/airports/AirportCodes.asp). | |
| 15 | 16 |  | 
| 16 | 17 | All the default options must exist. For `infantInSeatCount`, `infantInLapCount`, `seniorCount`, and `childCount`, leave them to the default value of `0` if its not necessary. | 
| 17 | 18 |  | 
| @@ -59,6 +60,17 @@ module Agents | ||
| 59 | 60 | } | 
| 60 | 61 | end | 
| 61 | 62 |  | 
| 63 | + form_configurable :qpx_api_key, type: :string | |
| 64 | + form_configurable :adultCount | |
| 65 | + form_configurable :origin | |
| 66 | + form_configurable :destination | |
| 67 | + form_configurable :date | |
| 68 | + form_configurable :childCount | |
| 69 | + form_configurable :infantInSeatCount | |
| 70 | + form_configurable :infantInLapCount | |
| 71 | + form_configurable :seniorCount | |
| 72 | + form_configurable :solutions | |
| 73 | + | |
| 62 | 74 | def validate_options | 
| 63 | 75 | errors.add(:base, "You need a qpx api key") unless options['qpx_api_key'].present? | 
| 64 | 76 | errors.add(:base, "Adult Count must exist") unless options['adultCount'].present? | 
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | require 'rails_helper' | 
| 2 | 2 |  | 
| 3 | -describe Agents::QpxAgent do | |
| 3 | +describe Agents::GoogleFlightsAgent do | |
| 4 | 4 | before do | 
| 5 | 5 |  | 
| 6 | 6 | stub_request(:post, "https://www.googleapis.com/qpxExpress/v1/trips/search?key=800deeaf-e285-9d62-bc90-j999c1973cc9").to_return( | 
| @@ -22,7 +22,7 @@ describe Agents::QpxAgent do | ||
| 22 | 22 | 'solutions'=> 3 | 
| 23 | 23 | } | 
| 24 | 24 |  | 
| 25 | - @checker = Agents::QpxAgent.new(:name => "tectonic", :options => @opts) | |
| 25 | + @checker = Agents::GoogleFlightsAgent.new(:name => "tectonic", :options => @opts) | |
| 26 | 26 | @checker.user = users(:bob) | 
| 27 | 27 | @checker.save! | 
| 28 | 28 | end |